import bar, { balanceBar, doubleMaxBar, maxBar, textBar } from "./bar"
import { baseVaule, type cardScript } from "../cardData/cardScript"
import part from "./part"
import { simpleListPart, simplePart } from "./part"

export default class cardType {
    name: string
    coverPart: part
    parts: part[]
    commonKeys: { [index: string]: string | cardScript } = {}
    constructor(name: string, coverPart: part, parts: part[], commonKeys: { [index: string]: string | cardScript } = {}) {
        this.name = name
        this.parts = parts
        this.coverPart = coverPart
        this.commonKeys = commonKeys
    }
}
//TODO coc导入
//TODO fe导入，初始值
export const internalCardTypeList: cardType[] = [
    new cardType('first epoch', {
        type: 'default',
        title: '简单信息',
        bars: [
            textBar('姓名', 'base_name'),
            new bar('simple', [
                { key: "123", option: { type: 'image' }, span: 12 },
                { key: "background_story", option: { type: 'textarea' }, span: 12, others: { lines: 5 } }]),
            doubleMaxBar("HP", { key: 'hp_value' }, { key: 'hp_max' },
                { key: 'hp_second_max', ...(baseVaule("hp_second_max", [{ key: 'attribute_phy', coefficient: 0.05 }])) },
                'hp_status', ['健康', '重伤', '濒死', "死亡"], ['#179b00', '#c90202', '#92140b', '#6c0000']),
            doubleMaxBar("MP", { key: 'mp_value' }, { key: 'mp_max' },
                { key: 'mp_second_max', ...(baseVaule("mp_second_max", [{ key: 'attribute_sol', coefficient: 0.05 }])) },
                'mp_status', ['充盈', '枯竭', '乱流', "魂灭"], ['#6f18c7', '#5b2e00', '#c700ab', '#000000'])
        ],
    }
        , [
            simplePart([
                textBar('姓名', 'base_name'),
                textBar('姓别', 'base_sex'),
                textBar('种族', 'base_race'),
                textBar('出身', 'base_hometown'),
                textBar('名誉', 'base_fame'),
                textBar('富裕', 'base_gold'),
            ], '基本信息'),
            simplePart([
                textBar('力量', 'attribute_pow', { type: 'rollable' }),
                textBar('体质', 'attribute_phy', { type: 'rollable' }),
                textBar('速度', 'attribute_spd', { type: 'rollable' }),
                textBar('智慧', 'attribute_int', { type: 'rollable' }),
                textBar('灵魂', 'attribute_sol', { type: 'rollable' }),
                textBar('魅力', 'attribute_cha', { type: 'rollable' }),
            ], '属性'),
            simplePart([
                textBar('行动点', 'action_point'),
                textBar('护甲点', 'armor_point'),
                textBar('抗性点', 'resistance_point'),
                textBar('幸运点', 'luck_point'),
                textBar('容纳点', 'slot_point'),
                textBar('命运点', 'fate_point'),
            ], '额外属性'),
            simplePart([
                new bar('simple', [{ value: '背景故事' }, { key: 'background_story', span: 24, option: { type: 'textarea' } }]),
                new bar('addable', [{ key: 'custom_describe_name', span: 8, option: { placeholder: "额外记述" } }, { key: 'custom_describe_value', span: 16 }])
            ], '描述'),
            simpleListPart([
                textBar('名称', 'weapon_name'),
                textBar('伤害', 'weapon_damage'),
                textBar('DB', 'weapon_DB'),
                textBar('AP', 'weapon_AP'),
                textBar('装填AP', 'weapon_reload'),
                textBar('武器计数', 'weapon_wp'),
                textBar('判定', 'weapon_dependent'),
                textBar('描述', 'weapon_describe'),
            ], '武器', 'weapon_name'),
            simplePart([
                new bar('simple', [{ value: '名称', span: 8 }, { value: '熟练度', span: 16 }]),
                new bar('addable', [{ key: 'skill_name', span: 8 }, { key: 'skill_value', span: 16 }])
            ], '技能'),
            simpleListPart([
                textBar('名称', 'power_name'),
                textBar('熟练度', 'power_value'),
                textBar('位阶', 'power_level'),
                textBar('描述', 'power_describe'),
                new bar('addable', [{ value: '技法', span: 6 }, { key: 'power_skill', span: 12, option: { placeholder: '名称' } }, { key: 'power_skill_describe', option: { type: 'textarea', placeholder: '效果描述' }, others: { lines: 2 } }])
            ], '权能', 'power_name'),
            simplePart([
                balanceBar('火', 'element_fire', 5, -5, { leftColor: '#f0563b', rightColor: '#6cafd8' }),
                balanceBar('水', 'element_water', 5, -5, { leftColor: '#3a84f3', rightColor: '#72583f' }),
                balanceBar('风', 'element_wind', 5, -5, { leftColor: '#daed4b', rightColor: '#68686f' }),
            ], '精灵魔法')
        ], {
        name: 'base_name',
        speed: 'attribute_spd'
    }),
    new cardType('call of cthulhu 7',
        simplePart([
            textBar('姓名', 'base_name'),
            new bar('simple', [{ key: "123", option: { type: 'image' }, span: 12 }, { key: "background_story", option: { type: 'textarea' }, span: 12, others: { lines: 5 } }]),
            maxBar("HP", { key: 'hp_value' }, { key: 'hp_max' }, 'hp_status', ['健康', '昏迷', '濒死', '死亡'], ['#179b00', '#c90202', '#92140b', '#2e0101']),
            maxBar("SAN", { key: 'san_value' }, { key: 'san_max' }, 'san_status', ['正常', '临时', '不定', '疯狂'], ['#8a7100', '#6f18c7', '#c700ab', '#000000']),
            textBar("幸运", "luck"),
            new bar('simple', [{ value: '魔法', span: 8 }, { key: "magic_value", span: 8 }, { key: "magic_max", span: 8 }])
        ], '简单信息'),
        [
            simplePart([
                textBar('姓名', 'base_name'),
                textBar('玩家', 'base_player'),
                textBar('年代', 'base_period'),
                textBar('职业', 'base_job'),
                textBar('序号', 'base_num'),
                textBar('年龄', 'base_age'),
                textBar('性别', 'base_sex'),
                textBar('住地', 'base_address'),
                textBar('故乡', 'base_hometown'),
            ], '调查员信息'),
            simplePart([
                textBar('力量', 'attribute_str'),
                textBar('敏捷', 'attribute_dex'),
                textBar('意志', 'attribute_pow'),
                textBar('体质', 'attribute_con'),
                textBar('外貌', 'attribute_app'),
                textBar('教育', 'attribute_edu'),
                textBar('体型', 'attribute_siz'),
                textBar('智力', 'attribute_int')
            ], '属性'),
            simplePart([
                textBar('移动力', 'sub_mov'),
                textBar('伤害加值', 'sub_db'),
                textBar('体格', 'sub_build'),
                textBar('闪避', 'sub_dodge'),
                textBar('护甲', 'sub_armor'),
            ], '补充属性'),
            simplePart([
                new bar('simple', [{ value: "标记", span: 1 }, { value: "名称", span: 1 }, { value: "初始", span: 1 }, { value: "成长", span: 1 }, { value: "职业", span: 1 }, { value: "兴趣", span: 1 }, { value: "总值", span: 1 }])

            ], '技能'),
            simplePart([

            ], '武器'),
            simplePart([

            ], '随身物品'),
            simplePart([

            ], '经历'),
            simplePart([

            ], '克苏鲁神话'),
            simplePart([

            ], '伙伴')
        ], {
        name: 'base_name',
        speed: 'attribute_spd'
    }
    )

]

export function checkCardType(obj: any): cardType | undefined {
    //TODO 检查cardType有效性
    return obj
}